using System;
using System.Collections.Generic;
using Framework.Core.Data;
using System.Reflection;

namespace Framework.Core.Search
{
    public static class SearchLogicFactory
    {
        public static SearchLogicItemCollection GetItems(DataBaseType dataBaseType)
        {
            SearchLogicItemCollection items = new SearchLogicItemCollection(new SearchLogicItem[0] { });

            try
            {
                Type type = Type.GetType(typeof(SearchLogicFactory).Namespace + "." + dataBaseType.ToString() + "SearchLogic");
                object obj = Activator.CreateInstance(type);
                PropertyInfo pi = type.GetProperty("Items");
                if (!object.Equals(pi, null))
                {
                    items = (SearchLogicItemCollection)pi.GetValue(obj, null);
                }
                return items;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
